
package net.atremmedia.gwt.actionjava.examples.bounds.samples;

import net.atremmedia.gwt.actionjava.examples.bounds.samples.curve.DrawCurve;
import net.atremmedia.gwt.actionjava.examples.frame.AJExampleOverview;
import actionjava.display.Graphics;
import actionjava.geom.Point2D;

public class DrawArcTo extends DrawCurve
{
	public static final String NAME = "Draw arcTo";
	public static final String DESCRIPTION = "Description";
	public static final String EXAMPLE_SRC = "https://code.google.com/p/gwt-actionjava/source/browse/trunk/aj-examples/aj-examples-bounds/src/main/java/net/atremmedia/gwt/actionjava/examples/bounds/samples/DrawArcTo.java";

	private Point2D p1;
	private Point2D cp1;
	private Point2D cp2;
	private int radius;

	/*
	 * ---------------------------------------------------------------
	 *	Constructor & init
	 * ---------------------------------------------------------------
	 */

	public DrawArcTo(AJExampleOverview base)
	{
		super(NAME, DESCRIPTION, EXAMPLE_SRC, base);
	}

	private void initialize()
	{
		// Start point
		p1 = new Point2D(200, 150);

		// Control point 1
		cp1 = new Point2D(450, 0);

		// Control point 2
		cp2 = new Point2D(355, 200);

		// Radius
		radius = 100;
	}

	/*
	 * ---------------------------------------------------------------
	 *	Abstract Overrides
	 * ---------------------------------------------------------------
	 */

	@Override
	public void run()
	{
		initialize();
		super.run(false);

		addChild(getCurveShape());
	}

	@Override
	public void drawCurve(Graphics graph)
	{
		graph.moveTo(p1.x, p1.y);
		graph.beginStroke(CURVE_LINE_COLOR);
		graph.arcTo(cp1.x, cp1.y, cp2.x, cp2.y, radius);
		graph.endStroke();
	}
}
